package ghost.gwtex.client;

/**
 * 
 * 该模块：仅限于针对GWT核心组件进行的扩展，与第三方组件、与后台均无关。
 * 
 * @author aibo zeng
 */

import java.util.Set;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GwtEx implements EntryPoint {
	public void onModuleLoad() {
		String value = "";
	    Dictionary dictionaryData = Dictionary.getDictionary("dictionaryData");
	    Set<String> keySet = dictionaryData.keySet();
	    for (String key : keySet) {
	       //该测试只有一个
	      // Get the value from the set
	      value = dictionaryData.get(key);	     
	    }
		
	    RootPanel.get().add(onInitializePanel(value.split(",")));
	    
	}

	public Widget onInitializePanel(String[] words) {
		    // Define the oracle that finds suggestions
		    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
		    for (int i = 0; i < words.length; ++i) {
		      oracle.add(words[i]);
		    }
		    // Create the suggest box
		    final SuggestBox suggestBox = new SuggestBox(oracle);
		    VerticalPanel suggestPanel = new VerticalPanel();
		    suggestPanel.add(new HTML("机构名称:"));
		    suggestPanel.add(suggestBox);

		    // Return the panel
		    return suggestPanel;
	}
	
}
